import Vue from 'vue';
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import 'normalize.css/normalize.css';
import App from './App.vue';
import router from './router';
import axios from 'axios';
import init from '@/mock'

init()

Vue.config.productionTip = false;
Vue.prototype.$http = axios;

Vue.use(ElementUI);

Vue.config.productionTip = false;
Vue.filter('dateFormat', function(originVal) {
  let newTime=new Date().getTime() //现在的时间
    let oldTime=new Date(originVal).getTime() // 原来的时间
    let dayTime=86400000 // 一天的毫秒数
    let yeatTime=dayTime*30 // 一个月的毫秒数
    let wekTime=dayTime*7 //一周的毫秒数
    let difference=newTime -oldTime //时间差
    let hourTime=3600000 // 一小时的毫秒数
    let MuterTime=60000 // 一分钟的毫秒数 
    if(difference>=yeatTime){
        return Math.floor(difference/yeatTime)+'月前'
    }else if(difference>=wekTime){
        return Math.floor(difference/wekTime)+'周前'
    }else if(difference>= dayTime){
        return Math.floor(difference/dayTime)+'天前'
    }else if(difference>=hourTime){
        return Math.floor(difference/hourTime)+'小时前'
    }else if(difference>=MuterTime){
        return Math.floor(difference/MuterTime)+'分钟前'
    }else{
        return newTime.getMilliseconds()+'秒'
    }
})
new Vue({
  router,
  render: h => h(App),
}).$mount('#app');
